<template>
  <view v-if="$props.type === 1">
    <uni-section title="单个动作用时" type="line">
      <view class="uni-px-4 uni-pb-4 flex">
        <view>
          <uni-easyinput type="number" v-model="time" placeholder="请输入单个动作用时"></uni-easyinput>
        </view>
        <text class="uni-pl-4">秒</text>
      </view>
    </uni-section>
    <uni-section title="动作数量" type="line">
      <view class="uni-px-4 uni-pb-4 flex">
        <view>
          <uni-easyinput type="number" v-model="amount" placeholder="请输入动作数量"></uni-easyinput>
        </view>
        <text class="uni-pl-4">秒</text>
      </view>
    </uni-section>
  </view>
  <uni-section title="休息间隔" type="line">
    <view class="uni-px-4 uni-pb-4 flex">
      <view>
        <uni-easyinput type="number" v-model="rest" placeholder="请输入休息间隔时间"></uni-easyinput>
      </view>
      <text class="uni-pl-4">秒</text>
    </view>
  </uni-section>
</template>

<script>
  export default {
    modal: 1,
    panel: 2
  }
</script>
<script setup>
  import { ref } from 'vue';
  const props = defineProps({
    type: Number,
  })
  const time = ref();
  const amount = ref();
  const rest = ref();
  const emit = defineEmits(['submit']);
  const submit = () => {
    if (
      !rest.value ||
      (props.type === 1 && (!time.value || !amount.value))
    ) {
      uni.showToast({
        icon: 'error',
        title: '请输入',
      })
      return;
    }
    emit('submit', {
      time: time.value,
      amount: amount.value,
      rest: rest.value,
    });
  };
  defineExpose({
    submit,
  })
</script>

<style lang="scss">
  .flex {
    display: flex;
    align-items: center;
    view {
      flex: 1;
    }
  }
  .vflex {
    display: flex;
    flex-direction: column;
    .main {
      flex: 1;
    }
  }
</style>
